<h1> Ranked Games </h1>
<style type="text/css">
A:link {text-decoration: none; color: #BCC1DD;}
A:visited {text-decoration: none; color: #BCC1DD;}
A:active {text-decoration: none}
A:hover {font-size:2430; font-weight:bold; color: #22AFCD;}
</style>
<?php

	// Set table template
	$tmpl = array (
    	'table_open'          => '<table border="6"  style="backgroud-color: #101225 ;" color="BCC1DD" id="mainTable_roster">',                  
        'heading_row_start'   => '<tr class="heading" id="table_headingstart_roster">',
        'heading_row_end'     => '</tr>',
        'heading_cell_start'  => '<th id="table_header_roster">',
        'heading_cell_end'    => '</th>',
        'row_start'           => '<tr id="table_rowstart_roster">',
        'row_end'             => '</tr>',
        'cell_start'          => '<td  id="main_content_roster">',
        'cell_end'            => '</td>',

        'row_alt_start'       => '<tr id="table_rowaltstart_roster">',
        'row_alt_end'         => '</tr>',
        'cell_alt_start'      => '<td id="table_footer_roster">',
        'cell_alt_end'        => '</td>',

        'table_close'         => '</table>'
	);
	
	$table_library->set_template($tmpl);

	// Create links on ongoing games' IDs to game set page
	$games_ongoing_table = $game_list_model->get_ongoing_games();
	
	
	foreach($games_ongoing_table as $key => $val){
		$games_ongoing_table[$key]['game_set_id'] = anchor('game/show/'. $val['game_set_id'], $val['game_set_id']);
		$games_ongoing_table[$key]['player2'] = anchor('profile/show/'. $val['player2'], $val['player2']);
		$games_ongoing_table[$key]['player1'] = anchor('profile/show/'. $val['player1'], $val['player1']);
		
	}

	// Generate table of completed challenges (game sets)
	echo "<h2>Current Ongoing Challenges</h2>";
	$table_library->set_heading('ID', 'Player 1', 'Player 2', 'P1 Wins', 'P2 Wins');
	echo $table_library->generate($games_ongoing_table);
  	$table_library->clear();
  	

	// Create links on completed games' IDs to game set page
	$games_completed_table= $game_list_model->get_recent_games();
	foreach($games_completed_table as $key => $val){
		$games_completed_table[$key]['game_set_id'] = anchor('game/show/'. $val['game_set_id'], $val['game_set_id']);
		$games_completed_table[$key]['player2'] = anchor('profile/show/'. $val['player2'], $val['player2']);
		$games_completed_table[$key]['player1'] = anchor('profile/show/'. $val['player1'], $val['player1']);
		
	}

	// Generate table of completed challenges (game sets)
	echo "<h2>Recently Completed Challenges</h2>";
	$table_library->set_heading('ID', 'Player 1', 'Player 2', 'P1 Wins', 'P2 Wins');
	echo $table_library->generate($games_completed_table);
  	$table_library->clear();	
	
?>
